char *skip_spaces(char *p);
char *trim_spaces(char *p);
char *next_token(char *p, char token, bool skip_spaces);
bool is_true_string(const char *str);
bool is_false_string(const char *str);

double center_points(double *point1, double *point2, double distance,
                     double max_distance=0);

struct assoc_array
    { const char *key; int value; };
bool assoc_match(const char *str, struct assoc_array array[],
                 int *return_index, int *return_value=0);
bool assoc_by_value(int value, struct assoc_array array[],
                    int *return_index, const char **return_key=0);

#define BIT(var,bit)           ((var) & (bit))
#define SET_BIT(var,bit)       ((var) |= (bit))
#define CLEAR_BIT(var,bit)     ((var) &= ~(bit))
#define TOGGLE_BIT(var, bit)   ((var) ^= (bit))
#define SWITCH_BIT(a,b)        { (a) ^= (b); \
                                 (b) ^= (a); \
                                 (a) ^= (b); }

#define FLAG(var,bit)          BIT((var),1 << (bit))
#define SET_FLAG(var,bit)      SET_BIT((var),1 << (bit))
#define CLEAR_FLAG(var,bit)    CLEAR_BIT((var),1 << (bit))
#define TOGGLE_FLAG(var,bit)   TOGGLE_BIT((var),1 << (bit))
